package com.kittlen.managementSystem.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.kittlen.managementSystem.entity.Admin;
import com.kittlen.managementSystem.entity.Notice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 公告表 Mapper 接口
 * </p>
 *
 * @author kittlen
 * @since 2021-01-26
 */
public interface NoticeMapper extends BaseMapper<Notice> {
    @Select("select n.*,a.fullname from t_notice n LEFT JOIN t_admin as a on a.admin_id=n.admin_id ${ew.customSqlSegment}")
    @ResultMap("com.kittlen.managementSystem.mapper.NoticeMapper.resultMap")
    List<Notice> selects(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Insert("insert into t_notice (notice_id,title,content,notice_type,notice_img,admin_id,create_date) values (#{notice.noticeId}," +
            "#{notice.title},#{notice.content},#{notice.noticeType},#{notice.noticeImg},#{notice.admin.adminId},now())")
    int insert(@Param("notice")Notice notice);
}
